package com.mmall.concurrency.example.Singleton;

import com.mmall.concurrency.annoations.NotThreadSafe;

/**
 * 懒汉模式
 * 单例实例在第一次使用时进行创建
 */
@NotThreadSafe
public class SingleExample1 {

    //私有构造函数
    private SingleExample1(){

    }

    //单例对象
    private static SingleExample1 instance = null;

    //静态工厂方法
    public static SingleExample1 getInstance(){
        if(instance == null){
            instance = new SingleExample1();
        }
        return instance;
    }

}
